//
//  MenuDomain.m
//  AppleCilent
//
//  Created by Nail Sharipov on 03/04/14.
//  Copyright (c) 2014 Nail Sharipov. All rights reserved.
//

#import "MenuDomain.h"
#import "MainProperties.h"


@implementation MenuDomain
{
    NSInteger menuId;
    NSString* name;
    NSString* description;
    NSString* ico;
    NSString* image;
    NSString* properties;
    NSArray* goods;
}
- (id)init:(NSDictionary*) data {
    self = [super init];
    menuId = [[data objectForKey:@"id"] intValue];
    name = [data objectForKey:@"name"];
    image = [data objectForKey:@"image"];
    ico = [data objectForKey:@"ico"];
    properties = [data objectForKey:@"properties"];
    NSArray* goodsData = [data objectForKey:@"goods"];
    
    NSMutableArray* goodsArray = [[NSMutableArray alloc] initWithCapacity:[goodsData count]];
    
    for (NSDictionary* dictionary in goodsData) {
        GoodsDomain* goodsDomain = [[GoodsDomain alloc] init:dictionary];
        [goodsArray addObject:goodsDomain];
    }
    goods = [[NSArray alloc] initWithArray:goodsArray];
    
    NSLog(@"menu %@ goods count: %i", name, [goods count]);
    
    
    return self;
}


- (NSInteger) getId
{
    return menuId;
}

- (NSString*) getName
{
    return name;
}

- (NSString*) getDescription
{
    return description;
}

- (NSString*) getIco
{
    return ico;
}

- (NSString*) getImage
{
    return image;
}

- (NSString*) getProperties
{
    return properties;
}

- (NSArray*) getGoods
{
    return goods;
}

@end
